package com.jin.gulimall.member.web;

import com.jin.common.utils.R;
import com.jin.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;
import java.util.Map;

@Controller
public class MemberWebController {

    @Autowired
    OrderFeignService orderFeignService;

    @GetMapping("/memberOrder.html")
    public String memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
                                  Model model){
        Map<String, Object> params = new HashMap<>();
        params.put("page", pageNum.toString());
        //查询出当前登录用户的所有订单数据
        //因为是请求的html页面，登录信息在cookies里，但是远程调用会丢失，所有需要配置
        R r = orderFeignService.listWithItem(params);
        System.out.println(r);
        model.addAttribute("orders", r);
        return "orderList";
    }
}
